
/**
 * copyright(c) 2013 www.jiongshibaoliao.com, All Rights Reserved.
 * project: jiongshibaoliao 
 * author: 曾帅
 * date: 2014-1-10 下午03:47:32
 * version: v1.0
 */

package com.jiongshibaoliao.dao.impl;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.jiongshibaoliao.dao.UserDao;
import com.jiongshibaoliao.exception.JiongException;
import com.jiongshibaoliao.mapper.BaseMapper;
import com.jiongshibaoliao.mapper.UserMapper;
import com.jiongshibaoliao.model.User;

/**
 * @project jiongshibaoliao
 * @author 曾帅 
 * @version 1.0
 * @date 2014-1-10 下午03:47:32   
 */

@Repository
public class UserDaoImpl extends BaseDaoImpl implements UserDao {

	@Autowired
	public UserMapper userMapper;
	
	/**
	 * 
	 * @author 曾帅
	 * @version 1.0
	 * @throws JiongException 
	 * @date 2014-1-10 下午03:47:55
	 * @see com.jiongshibaoliao.dao.BaseDao#delete(long)
	 */
	@Override
	public void delete(long id) throws JiongException {
		throw new JiongException("无权执行此操作！");
	}

	
	/**
	 * 
	 * @author 曾帅
	 * @version 1.0
	 * @date 2014-1-10 下午09:40:27
	 * @see com.jiongshibaoliao.dao.impl.BaseDaoImpl#getMapper()
	 */
	@Override
	public BaseMapper getMapper() {
		return userMapper;
	}


	
	/**
	 * 
	 * @author 曾帅
	 * @version 1.0
	 * @date 2014-1-16 下午04:59:21
	 * @see com.jiongshibaoliao.dao.UserDao#findUserByLoginNameAndPwd(java.lang.String, java.lang.String)
	 */
	@Override
	public User findUserByLoginNameAndPwd(String loginName, String passWord) {
		Map<String, String> map = new HashMap<String, String>();
		map.put("loginName", loginName);
		map.put("passWord", passWord);
		
		return userMapper.findUserByLoginNameAndPwd(map);
	}


	
	/**
	 * 
	 * @author 曾帅
	 * @version 1.0
	 * @date 2014-2-8 下午04:48:59
	 * @see com.jiongshibaoliao.dao.UserDao#getUserIdByLoginName(java.lang.String)
	 */
	@Override
	public long getUserIdByLoginName(String loginName) {
		return userMapper.getUserIdByLoginName(loginName);
	}


	
	/**
	 * 
	 * @author 曾帅
	 * @version 1.0
	 * @date 2014-2-9 下午08:33:26
	 * @see com.jiongshibaoliao.dao.UserDao#isUserExist(java.lang.String)
	 */
	@Override
	public boolean isUserExist(String loginName) {
		return userMapper.isUserExist(loginName) > 0 ? true : false;
	}

}
